//
//  UISlider+ZFSlider.m
//  CBT
//
//  Created by Mr.Zhang on 2019/3/11.
//  Copyright © 2019 Mr.Zhang. All rights reserved.
//

#import "UISlider+ZFSlider.h"

#import <objc/runtime.h>

@implementation UISlider (ZFSlider)

- (CGFloat)zf_trackHeight
{
    return [objc_getAssociatedObject(self, @selector(zf_trackHeight)) floatValue];
}

- (void)setZf_trackHeight:(CGFloat)zf_trackHeight
{
    objc_setAssociatedObject(self, @selector(zf_trackHeight), @(zf_trackHeight), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
    [self setNeedsDisplay];
}

- (CGRect)zf_trackRectForBounds:(CGRect)bounds
{
    CGRect trackRect = [self zf_trackRectForBounds:bounds];
    
    if (self.zf_trackHeight > 0.0f) {
        trackRect.size.height = self.zf_trackHeight;
    }
    return trackRect;
}

+ (void)load
{
    method_exchangeImplementations(class_getInstanceMethod(self, @selector(trackRectForBounds:) ), class_getInstanceMethod(self, @selector(zf_trackRectForBounds:) ) );
}

@end
